package com.bilibili.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bilibili.entity.CommonResult;
import com.bilibili.entity.User;
import com.bilibili.service.FollowService;
import com.bilibili.service.UserService;
import com.bilibili.service.impl.FollowServiceImpl;
import com.bilibili.service.impl.UserServiceImpl;

@WebServlet("/upandvideo.do")
public class UpMasterAndVideoServlet extends HttpServlet {
	
	private UserService us= new UserServiceImpl();
	private FollowService fs = new FollowServiceImpl();
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("application/json;charset=utf-8");
		CommonResult cr=new CommonResult();
		int upId = -1;
		try {
			upId = Integer.parseInt(request.getParameter("upId"));
		}catch (Exception e) {
			// TODO: handle exception
		}
		User u = us.selectUpAllInfo(upId);
		List<Object> list = new ArrayList<Object>();
		list.add(u);
		list.add(fs.selectUpFS(upId));
		if(u != null) {
			cr.setCode(200);
			cr.setMassage("success");
			cr.setData(list);
		}
		response.getWriter().write(cr.toJSONString());
	}

}
